package practice_0524;

import java.util.Scanner;

public class practice04 {
    public static void main(String[] args) {
//        char[][] arr = new char[8][10];
        int[][] score = new int[50][5];
        Scanner scanner = new Scanner(System.in);
        int chinese,math,english,id;
        System.out.println("请输入要录入成绩的学生数量：");
        int num_stu = scanner.nextInt();
        int count = 0;
        for (int i = 0; i < score.length; i++) {
            System.out.println("请输入第" + (i + 1)+ "个学生的编号");
            id = scanner.nextInt();
            System.out.println("请输入第" + (i + 1)+ "个学生的语文成绩：");
            chinese = scanner.nextInt();
            System.out.println("请输入第" + (i + 1)+ "个学生的数学成绩：");
            math = scanner.nextInt();
            System.out.println("请输入第" + (i + 1)+ "个学生的英语成绩：");
            english = scanner.nextInt();
            score[i][0] = id;
           //成绩每一行的第一个数据被学生编号占了，所以这里减一
            score[i][1] = chinese;
            score[i][2] = math;
            score[i][3] = english;
            score[i][4] = english+ math + chinese;
            if(num_stu == ++count){
                break;
            }

        }
        System.out.println("学生编号\t语文成绩\t数学成绩\t英语成绩\t平均成绩\t\t总成绩");
        for (int i = 0; i < score.length; i++) {
            if(score[i][0] == 0.0){
                break;
            }
            for (int j = 0; j < score[0].length ; j++) {
                if(j < score[0].length - 1){
                    System.out.print(score[i][j] + "\t\t");
                }

            }
            String avg_num = String.format("%.2f",(double)(score[i][1] +score[i][2] + score[i][3])/3);
            System.out.print(avg_num +"\t\t");
            System.out.println(score[i][score[0].length - 1]);
        }

    }
}
